/*thread_creat.c*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct student
{
    int age;
    char name[20];
} STU;
void *create(void *arg)
{ // 线程将要执行的代码
    STU *temp = (STU *)arg;
    printf("The following is transferred to thread\n");
    printf("STU age is %d\n", temp->age);
    printf("STU name is %s\n", temp->name);
}
int main(int argc, char *argv[])
{
    pthread_t tidp;
    int error;
    STU *stu = (STU *)malloc(sizeof(STU));
    stu->age = 20;
    strcpy(stu->name, "abcdefg");
    error = pthread_create(&tidp, NULL, create, (void *)stu);
    if (error != 0)
    {
        printf("pthread_create failed ");
        return -1;
    }

    pthread_join(tidp, NULL);
    return 0;
}
